<!--
 * @Descripttion: 
 * @version: 
 * @Author: lsy
 * @Date: 2022-01-25 15:08:49
 * @LastEditors: lsy
 * @LastEditTime: 2022-01-26 17:47:55
-->
<template>
    <h1 @click="changeLogin">hello,I am app1嘿嘿{{ msg1 }}</h1>
    <router-link to="/page1">去app1的page1</router-link>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue';

const { proxy } = getCurrentInstance();

const changeLogin = () => {
    proxy.setGlobalState({ msg: "head123", })
}

const msg1 = ref("");

if (window.GlobalState) {
    proxy.onGlobalStateChange((state, prev) => {
        // state: 变更后的状态; prev 变更前的状态
        msg1.value = state.msg;
    }, true);
}

</script>